package com.zpy.playground.nulltest;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;

@RestController
@RequestMapping("/fastjson")
public class FastJsonController {
    @AllArgsConstructor
    @NoArgsConstructor
    @Data
    static class A {
        private String a;
        private Integer b;
    }

    @PostMapping("/get")
    public void get() {
        A a1 = new A("a", 1);
        A a2 = new A("b", 2);
        ArrayList<A> list = new ArrayList<A>() {{
            add(a1);
            add(a2);
        }};

        System.out.println(JSON.toJSONString(a1));
        System.out.println(JSONObject.toJSONString(a1));
        System.out.println(JSON.toJSONString(list));
        System.out.println(JSONObject.toJSONString(list));
        System.out.println(a1);
        System.out.println(a2);
        System.out.println(list);
    }
}
